﻿using System;
using UnityEditor;
using UnityEngine;

namespace Game.UI {
    public class UIWindow : MonoBehaviour {
        public bool IsOpen {
            get {
                return gameObject.activeInHierarchy;
            }
        }

        private void Awake() {
            onInit();
        }

        private void OnDestroy() {
            onDestroy();
        }

        protected virtual void onInit(){}
        
        public virtual void Open(object[] args) {
            gameObject.SetActive(true);
            onOpen(args);
        }

        protected virtual void onOpen(object[] args) { }

        public virtual void Close() {
            gameObject.SetActive(false);
            onClose();
        }

        protected virtual void onClose() { }
        
        protected virtual void onDestroy() { }
    }
}